﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

namespace ProjectBase.Core
{
    /// <summary>
    ///     IReadDao will get the templated entity 'T' from the storage
    ///     1) as the IList&lt;T&gt; using filtering parameters
    ///     or 2) as the SingleOrDefault() instance using its unique ID.
    /// </summary>
    /// <typeparam name = "T">templated entity which has its persisted representation</typeparam>
    /// <typeparam name = "TID">unique identifier. suggested types are decimal, int, short, long, Guid and string</typeparam>
    /// <typeparam name = "TFilter"></typeparam>
    [ContractClass(typeof(Diagnostics.ReadDao<,,>))]
    public interface IReadDao<out T, in TID, in TFilter> : IReadDao<T, TID>
        where T : class, IPersistentObjectWithTypedId<TID>
        where TFilter : class, IFilter<TID>
    {
        /// <summary>
        ///     Get the list of entities which properties match the filter criteria
        ///     in the IFilter filterObject
        /// </summary>
        /// <param name = "filter">the instance of the entity's specific filtering criteria object</param>
        /// <returns></returns>
        IEnumerable<T> Find(TFilter filter);
    }

    [ContractClass(typeof(Diagnostics.ReadDao<,>))]
    public interface IReadDao<out T, in TID> : IDao
        where T : class, IPersistentObjectWithTypedId<TID>
    {
        /// <summary>
        ///     Returns the SingleOrDefault instance of the entity 'T' with the provided unique ID
        /// </summary>
        /// <param name = "id">unique identifier</param>
        /// <returns>Single value or the default(T)</returns>
        T GetById(TID id);
    }
}